package com.training.api.service;

import com.training.api.repository.CourseRepository;
import com.training.bean.Course;
import com.training.bean.CourseContent;
import com.training.bean.CourseStage;
import com.training.api.repository.CourseContentRepository;
import com.training.api.repository.CourseStageRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Optional;

@Service
public class CourseService {
    
    @Autowired
    private CourseStageRepository stageRepository;
    
    @Autowired
    private CourseRepository courseRepository;
    
    @Autowired
    private CourseContentRepository contentRepository;
    
    // CourseStage相关方法
    public List<CourseStage> getAllStage() {
        return stageRepository.findAll();
    }

    public List<Course> getCoursesWithCollectAndProgress(int csid, int uid) {
        return courseRepository.findCoursesWithCollectAndProgressByCSId(csid, uid);
    }
    
    public Optional<Course> findCourse(int id) {
        return courseRepository.findById(id);
    }


    
    // CourseContent相关方法
    public List<CourseContent> getAllCourseContent(int cid) {
        return contentRepository.findCourseContentByCId(cid);
    }
}